class ResponseBean {
  id: string;
  statusCode: number;
  headers: Record<string, string>;
  body: string;
  createTime: Date;

  constructor(
    id: string,
    statusCode: number,
    headers: Record<string, string>,
    body: string,
    createTime: Date
  ) {
    this.id = id;
    this.statusCode = statusCode;
    this.headers = headers;
    this.body = body;
    this.createTime = createTime;
  }

  toJson(): Record<string, any> {
    return {
      id: this.id,
      statusCode: this.statusCode,
      headers: this.headers,
      body: this.body,
      createTime: this.createTime.toISOString(),
    };
  }

  static fromJson(json: Record<string, any>): ResponseBean {
    return new ResponseBean(
      json['id'],
      json['statusCode'],
      json['headers'],
      json['body'],
      new Date(json['createTime'])
    );
  }
}

export default ResponseBean;
